package project3.datasets;

import java.util.logging.Logger;

import project3.datasets.parsers.DataSetParser;


/**
 * Support class for DataSet implementers. 
 * 
 * @author Vika
 * @author Antonio
 */
public abstract class AbstractDataSet implements DataSet  {

	protected final Logger _log = Logger.getLogger(getClass().getName());
	
	/** The dataset's name */
	protected String name;

	/** The dataset's array of attributes */
	protected Attribute[] attributes;
	
	/**
	 * Constructs a new <code>DataSet</code> by passing a dataset parser. 
	 */
	public AbstractDataSet(DataSetParser parser) {
		this.name = parser.getDataSetName();
		this.attributes = parser.getAttributes();
		
		Instance instance;
		while ((instance = parser.nextRow()) != null) {
			this.addInstance(instance);
		}
	}

	protected abstract void addInstance(Instance instance);

	/**
	 * @return Returns the attributes.
	 */
	public Attribute[] getAttributes() {
		return attributes;
	}

	/**
	 * @return Returns the name.
	 */
	public String getName() {
		return name;
	}
}
